<template>
    <template v-for="item in routers" :key="item.id">
                  <el-sub-menu v-if="item.children" :key="item.id" :index="item.id.toString()" style="color:red">
                    <template #title>
                      <el-icon>
                        <component v-if="item.iconCls" :is="item.iconCls"></component>
                      </el-icon>
                      <span v-if="item.meta">{{item.meta.title}}</span>
                    </template>
                    
                      <!--二级菜单-->
                      <el-menu-item v-for="item2 in item.children" 
                        :key="item2.id" 
                        :index="item2.path.toString()">
                        <template #title>
                          <el-icon>
                            <component v-if="item2.iconCls" :is="item2.iconCls"></component>
                          </el-icon>
                          <span v-if="item2.meta">{{item2.meta.title}}</span>
                        </template>
                      </el-menu-item>
                    
                  </el-sub-menu>

                  <el-menu-item  v-else :key="item['id']" :index="item.path.toString()">
                    <template #title>
                      <el-icon>
                        <component v-if="item.iconCls" :is="item.iconCls"></component>
                      </el-icon>
                      <span v-if="item.meta">{{item.meta.title}}</span>
                    </template>
                  </el-menu-item>
                </template>
</template>

<script>
export default{
    // eslint-disable-next-line vue/multi-word-component-names
    name:'Sidebar',
    props:{
        routers:Array
    }
}
</script>
<style scoped>

.el-menu-item{
  background-color: #2c3e50;
  color: white;
}

.el-sub-menu{
  background-color: #2c3e50;
  color: white;
}
.el-sub-menu /deep/ .el-sub-menu__title{
  color: white;
}

.el-sub-menu :hover{
  background-color: rgb(3, 46, 83); 
  color: white;
}

.el-menu-item:before {
    background: #425668;
    bottom: auto;
    content: "";
    height: 8px;
    left: 23px;
    margin-top: 15px;
    position: absolute;
    right: auto;
    width: 8px;
    z-index: 1;
    border-radius: 50%;
}
.el-menu-item:after {
    border-left: 1px solid #425668;
    bottom: 0;
    content: "";
    left: 27px;
    position: absolute;
    top: 0;
}
</style>